IF EXISTS (SELECT * FROM sysobjects WHERE type = 'V' AND name = 'VW_ClientFetch')
	BEGIN
		DROP  View VW_ClientFetch
	END
GO

CREATE View VW_ClientFetch AS

SELECT
	c.ClientId, c.Code, c.Guid, u.UserId, u.Username, u.Password, u.FullName, u.Sid, u.TypeFlag
FROM Clients AS c
INNER JOIN Users AS u ON u.ClientId = c.ClientId
WHERE u.PrimaryUser = 1

GO